//
//  STOrderFooter1View.m
//  YiYueStore
//
//  Created by zhouzhouzhou on 2018/9/28.
//  Copyright © 2018年 YuYiLian. All rights reserved.
//

#import "STOrderFooter1View.h"
#import "UIButton+ZYHblock.h"
#import "YLHomeOrderListModel.h"
@implementation STOrderFooter1View


-(id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    //加载用户信息
    if (self) {
        self.autoresizesSubviews = NO;
        STOrderFooter1View * userView =  [[NSBundle mainBundle] loadNibNamed:@"STOrderFooter1View"owner:self options:nil].lastObject;
        self = userView;
        self.frame = frame;
    }
    return self;
}

-(void)setOrderFooterViewWithType:(int)type data:(id)extraData{
    YLHomeOrderListModel * listModel = extraData;
    orderType = type;
    [self.msgBtn changeButtonImgTopTextBottom];
    [self.telBtn changeButtonImgTopTextBottom];
    
    if (type == 0) {
        self.priceView.hidden = YES;
        self.communicateView.hidden = NO;
        self.agreeBtn.backgroundColor =ButtonBackColor;
        self.refuseBtn.backgroundColor = [UIColor orangeColor];
        
        if ([listModel.status integerValue] == 13) {
            [self.agreeBtn setTitle:@"同意" forState:UIControlStateNormal];
            [self.refuseBtn setTitle:@"违约退款" forState:UIControlStateNormal];
        }else if ([listModel.status integerValue] == 8) {
            [self.agreeBtn setTitle:@"发送提醒" forState:UIControlStateNormal];
            [self.refuseBtn setTitle:@"取消" forState:UIControlStateNormal];
        }else if ([listModel.status integerValue] == 3) {
            [self.agreeBtn setTitle:@"同意" forState:UIControlStateNormal];
            [self.refuseBtn setTitle:@"拒绝接单" forState:UIControlStateNormal];
        }
        
        
    }else if (type == 1){
        if ([listModel.status integerValue] == 4) {
            self.priceView.hidden = YES;
            self.communicateView.hidden = NO;
            self.agreeBtn.backgroundColor = ButtonBackColor;
            self.refuseBtn.backgroundColor = [UIColor orangeColor];
            [self.agreeBtn setTitle:@"开始服务" forState:UIControlStateNormal];
            [self.refuseBtn setTitle:@"取消订单" forState:UIControlStateNormal];
        }else if ([listModel.status integerValue] == 7) {
            self.priceView.hidden = NO;
            self.communicateView.hidden = YES;
            self.agreeBtn.backgroundColor = ButtonBackColor;
            self.refuseBtn.backgroundColor = [UIColor orangeColor];
            [self.agreeBtn setTitle:@"完成服务" forState:UIControlStateNormal];
            [self.refuseBtn setTitle:@"加价" forState:UIControlStateNormal];
            float  total = [listModel.orderAddMoney.addmoney floatValue]+[listModel.orderAmount floatValue];
            NSString * totalStr = [NSString stringWithFormat:@"¥%.2f",total];
            self.priceLab.text = totalStr;
        }
        
    }else if(type == 2){
        self.priceView.hidden = YES;
        self.communicateView.hidden = NO;
        self.refuseBtn.hidden = YES;
        self.agreeBtn.backgroundColor = [UIColor orangeColor];
        if([listModel.status integerValue] == 11){
            [self.agreeBtn setTitle:@"邀请评价" forState:UIControlStateNormal];
        }else if([listModel.status integerValue] == 18){
            [self.agreeBtn setTitle:@"查看评价" forState:UIControlStateNormal];
            
        }
    }else if (type == 3){
        self.hidden = YES;
    }
}

- (IBAction)actionTel:(id)sender {
    [self sentActionTypeToController:telBtnAction];
}

- (IBAction)actionMsg:(id)sender {
    [self sentActionTypeToController:msgBtnAction];
}

- (IBAction)actionAgree:(id)sender {
    [self sentActionTypeToController:agreeBtnAction];
}

- (IBAction)actionRefuse:(id)sender {
    [self sentActionTypeToController:refuseBtnAction];
}

-(void)sentActionTypeToController:(STOrderFooter1ViewActionType)type{
    if ([self.footerDelegate respondsToSelector:@selector(orderFooter1ViewWithActionType:orderType:)]) {
        [self.footerDelegate orderFooter1ViewWithActionType:type orderType:orderType];
    }
        
}
/*
 else if (type == 4){
 self.priceView.hidden = NO;
 self.communicateView.hidden = YES;
 self.agreeBtn.backgroundColor = ButtonBackColor;
 self.refuseBtn.backgroundColor = [UIColor orangeColor];
 [self.agreeBtn setTitle:@"完成服务" forState:UIControlStateNormal];
 [self.refuseBtn setTitle:@"加价" forState:UIControlStateNormal];
 self.priceLab.text = @"¥580";
 }else if (type == 6 ){
 self.priceView.hidden = YES;
 self.communicateView.hidden = NO;
 self.refuseBtn.hidden = YES;
 self.agreeBtn.backgroundColor = [UIColor orangeColor];
 [self.agreeBtn setTitle:@"取消订单" forState:UIControlStateNormal];
 }else if (type == 7){
 
 self.priceView.hidden = YES;
 self.communicateView.hidden = NO;
 self.agreeBtn.backgroundColor = ButtonBackColor;
 self.refuseBtn.backgroundColor = [UIColor orangeColor];
 [self.agreeBtn setTitle:@"开始服务" forState:UIControlStateNormal];
 [self.refuseBtn setTitle:@"取消订单" forState:UIControlStateNormal];
 }else if (type == 8 || type == 9){
 self.priceView.hidden = YES;
 self.communicateView.hidden = NO;
 self.refuseBtn.hidden = YES;
 self.agreeBtn.backgroundColor = [UIColor orangeColor];
 if(type == 8){
 [self.agreeBtn setTitle:@"查看评价" forState:UIControlStateNormal];
 }else{
 [self.agreeBtn setTitle:@"邀请评价" forState:UIControlStateNormal];
 }
 }
 */
@end
